package com.spzx.payment.api.factory;

import com.spzx.common.core.domain.R;
import com.spzx.payment.api.RemotePaymentInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.context.annotation.Configuration;

/**
 * ClassName: RemotePaymentInfoFallbackFactory
 * Package: com.spzx.payment.api.factory
 * Description:
 *
 * @Author 梅超凡
 * @Create 2025/1/6 10:56
 * @Version 1.0
 */
@Slf4j
@Configuration
public class RemotePaymentInfoFallbackFactory implements FallbackFactory<RemotePaymentInfoService> {
    @Override
    public RemotePaymentInfoService create(Throwable throwable) {
        log.error("支付服务调用失败:{}", throwable.getMessage());
        return new RemotePaymentInfoService(){
            @Override
            public R<Object> savePaymentInfoTradeNo(
                                                    String tradeNo, String source) {
                return R.fail("保存支付号失败:" + throwable.getMessage());
            }
        };
    }
}
